package lock;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zfj
 * @date 2021/10/17 -14:15
 * 测试线程池
 */

public class TestPool {
	public static void main(String[] args) {
		//创建服务，创建线程池
		ExecutorService service= Executors.newFixedThreadPool(10);
		service.execute(new MyThread());
		service.execute(new MyThread());
		service.execute(new MyThread());
		service.execute(new MyThread());
		//关闭连接
		service.shutdown();
	}
}

class MyThread implements Runnable{

	/**
	 * When an object implementing interface <code>Runnable</code> is used
	 * to create a thread, starting the thread causes the object's
	 * <code>run</code> method to be called in that separately executing
	 * thread.
	 * <p>
	 * The general contract of the method <code>run</code> is that it may
	 * take any action whatsoever.
	 *
	 * @see Thread#run()
	 */
	@Override
	public void run() {
			System.out.println(Thread.currentThread().getName());
	}
}